package com.shilin.watchsystem.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Slf4j
@Component
public class MetaHandler implements MetaObjectHandler {



    @Override
    public void insertFill(MetaObject metaObject) {
        /**
         * insert更新创建时间
         */
        log.info("start insert fill ....");
        this.strictInsertFill(metaObject, "createDtm", LocalDateTime.class, LocalDateTime.now()); // 起始版本 3.3.0(推荐使用))
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        /**
         * update更新更新时间
         */
        log.info("start update fill ....");
        this.strictUpdateFill(metaObject, "updateDtm", LocalDateTime.class, LocalDateTime.now()); // 起始版本 3.3.0(推荐使用)
    }
}
